Shader "Lch/LchPagePush"
{
    Properties
    {
        _BaseColor_Tex("Base Texture", 2D) = "white" {}
        _BaseColor_Tex2 ("Base Texture2", 2D) = "white" {}
        _Offset("Offset", Range(0, 1)) = 0
    }
    SubShader
    {
        Tags
        {
            "RenderPipeline"="UniversalPipeline"
            "RenderType"="AlphaTest"
            "Queue"="Geometry"
        }

        Pass
        {

             Name "ForwardLit"
            Tags{"LightMode" = "UniversalForward"}

            
            ZWrite On 
    
            HLSLPROGRAM

 

 
 
 
 
 
   
  
            //#define _SPECGLOSSMAP
            
            
            //_ADDITIONAL_LIGHT_SHADOWS _LIGHT_LAYERS _MAIN_LIGHT_SHADOWS_CASCADE _SHADOWS_SOFT
            #define _NORMALMAP  

            #define MAIN_LIGHT_CALCULATE_SHADOWS
            #ifdef _NORMALMAP
            #define REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR 

            #endif

     
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary\Lighting.hlsl"
          
 
            #include "LchPagePushInput.hlsl"

            #define CUSTOM_VERTEX_PARAM 
            #include "lch_urp_com.hlsl"
 
            
            #pragma vertex vert
            #pragma fragment frag
           

           
         
            
            Varyings vert(Attributes input)
            {
                Varyings output = (Varyings)0;
                UNITY_SETUP_INSTANCE_ID(input);
                UNITY_TRANSFER_INSTANCE_ID(input, output);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
                FillVaryingsData( input, output);
                output.uv = TRANSFORM_TEX(output.uv, _BaseColor_Tex2);
              
        

 
                return output;
            }
           
            half3 CalculateLight(Light light, InputData inputData )
            {
                half3 attenuatedLightColor = light.color * (light.distanceAttenuation * light.shadowAttenuation);
                half3 baseLight = attenuatedLightColor*  dot(light.direction, inputData.normalWS);
                half3 lightColor = max( baseLight,0)  ; 
  
                return lightColor;
            }
            half4 frag(Varyings input,bool isFrontFace : SV_IsFrontFace) : SV_Target
            {

                UNITY_SETUP_INSTANCE_ID(input);
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);

                float2 t1 = input.uv;

 
                half4 final_color = half4(_Offset, 0, 0.0, 1.0);
                float r = 1.0 - _Offset;
                if (t1.x >= r)
                {
                    final_color = SAMPLE_TEXTURE2D(_BaseColor_Tex2, sampler_BaseColor_Tex2, float2(t1.x - r, t1.y));
                }
                else
                {
                    final_color =  SAMPLE_TEXTURE2D(_BaseColor_Tex, sampler_BaseColor_Tex, float2(t1.x - r + 1.0, t1.y));
                }

                return final_color;

       
            }
            ENDHLSL
        }

         Pass
        {
            Name "ShadowCaster"
            Tags{"LightMode" = "ShadowCaster"}

            ZWrite On
            ZTest LEqual
            ColorMask 0
            Cull[_Cull]

            HLSLPROGRAM
 

  
            #pragma shader_feature_local_fragment _ALPHATEST_ON
            //#pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A

            //--------------------------------------
            // GPU Instancing
            #pragma multi_compile_instancing
            //#pragma multi_compile _ DOTS_INSTANCING_ON
            // -------------------------------------
            // Universal Pipeline keywords

            // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
            //#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW

            #pragma vertex ShadowPassVertex
            #pragma fragment ShadowPassFragment

            #pragma multi_compile_vertex _ _ALPHATEST_ON
       
 
            #include "LchPagePushInput.hlsl"
         
            
            #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
            
            

             
            ENDHLSL
        }

         


        Pass
        {
            Name "DepthOnly"
            Tags{"LightMode" = "DepthOnly"}

            ZWrite On
            ColorMask 0
            Cull[_Cull]

            HLSLPROGRAM
 
   

            #pragma vertex DepthOnlyVertex
            #pragma fragment DepthOnlyFragment

            // -------------------------------------
            // Material Keywords
            #pragma shader_feature_local_fragment _ALPHATEST_ON
           // #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A

            //--------------------------------------
            // GPU Instancing
            #pragma multi_compile_instancing
            //#pragma multi_compile _ DOTS_INSTANCING_ON

            
 
            #include "LchPagePushInput.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
            ENDHLSL
        }

        
    }
    FallBack "Hidden/Shader Graph/FallbackError"

    CustomEditor "LCHShaderGUIBase" 
}